/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.wisnu.ebs.view;

import com.wisnu.ebs.controller.MainController;
import java.awt.Color;
import javax.swing.ImageIcon;

/**
 *
 * @author Wisnu Wardoyo <mas.wisnu99@gmail.com>
 */
public class ToolPanel extends javax.swing.JPanel {

    /**
     * Creates new form toolPanel
     */
    private MainController controller;
    private int id = 0;

    public ToolPanel() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labPrev = new javax.swing.JLabel();
        labNext = new javax.swing.JLabel();
        labSetting = new javax.swing.JLabel();

        setBackground(new Color(225,225,225,20));
        addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                formMouseMoved(evt);
            }
        });

        labPrev.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labPrev.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/prev.png"))); // NOI18N
        labPrev.setToolTipText("PREVIOUS");
        labPrev.setPreferredSize(new java.awt.Dimension(60, 60));
        labPrev.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                labPrevMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                labPrevMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                labPrevMouseExited(evt);
            }
        });

        labNext.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labNext.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/next.png"))); // NOI18N
        labNext.setToolTipText("NEXT");
        labNext.setPreferredSize(new java.awt.Dimension(60, 60));
        labNext.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                labNextMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                labNextMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                labNextMouseExited(evt);
            }
        });

        labSetting.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labSetting.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/setting.png"))); // NOI18N
        labSetting.setToolTipText("PENGATURAN");
        labSetting.setPreferredSize(new java.awt.Dimension(60, 60));
        labSetting.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                labSettingMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                labSettingMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                labSettingMouseExited(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labPrev, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(labNext, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(labSetting, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(labNext, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(labPrev, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(labSetting, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void labPrevMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labPrevMouseEntered
        
        if(labPrev.isEnabled())labPrev.setIcon(new ImageIcon("./src/icon/prevHover.png"));
        controller.repaint();
    }//GEN-LAST:event_labPrevMouseEntered

    private void labPrevMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labPrevMouseExited
        labPrev.setIcon(new ImageIcon("./src/icon/prev.png"));
        controller.repaint();
    }//GEN-LAST:event_labPrevMouseExited

    private void labNextMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labNextMouseEntered
        if(labNext.isEnabled())labNext.setIcon(new ImageIcon("./src/icon/nextHover.png"));
        controller.repaint();
    }//GEN-LAST:event_labNextMouseEntered

    private void labNextMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labNextMouseExited
        labNext.setIcon(new ImageIcon("./src/icon/next.png"));
        controller.repaint();
    }//GEN-LAST:event_labNextMouseExited

    private void labSettingMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labSettingMouseEntered
        labSetting.setIcon(new ImageIcon("./src/icon/settingHover.png"));
        controller.repaint();
    }//GEN-LAST:event_labSettingMouseEntered

    private void labSettingMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labSettingMouseExited
        labSetting.setIcon(new ImageIcon("./src/icon/setting.png"));
        controller.repaint();
    }//GEN-LAST:event_labSettingMouseExited

    private void formMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseMoved
        controller.repaint();
    }//GEN-LAST:event_formMouseMoved

    private void labPrevMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labPrevMouseClicked
        switch (id) {
            case 1:
                controller.savingState();
                controller.openingConfigurationPanel();
                break;
            case 2:
                controller.savingState();
                controller.openingKeyPanel();
                break;
            case 3:
                controller.savingState();
                controller.openingAnswerPanel();
                break;
        }

    }//GEN-LAST:event_labPrevMouseClicked

    private void labNextMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labNextMouseClicked
        switch (id) {
            case 1:
                controller.savingState();
                controller.openingAnswerPanel();
                break;
            case 2:
                controller.savingState();
                controller.openingResultPanel();
                break;
            case 3:
                break;
        }
    }//GEN-LAST:event_labNextMouseClicked

    private void labSettingMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labSettingMouseClicked
        controller.savingState();
        controller.openingConfigurationPanel();
    }//GEN-LAST:event_labSettingMouseClicked


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel labNext;
    private javax.swing.JLabel labPrev;
    private javax.swing.JLabel labSetting;
    // End of variables declaration//GEN-END:variables
    public void setController(MainController controller) {
        this.controller = controller;
    }

    public void setID(int id) {
        this.id = id;
    }

    public void setting(int id) {
        switch (id) {
            case 1:
                labPrev.setEnabled(false);
                labNext.setEnabled(true);
                break;
            case 2:
                labPrev.setEnabled(true);
                labNext.setEnabled(true);
                break;
            case 3:
                labPrev.setEnabled(true);
                labNext.setEnabled(false);
                break;
        }
    }

}
